package com.findme.test.itext.pdf;

import com.itextpdf.text.BaseColor;
import com.itextpdf.text.DocumentException;
import com.itextpdf.text.Font;
import com.itextpdf.text.pdf.BaseFont;

import java.io.IOException;

/**
 * @ClassName: FontFactory
 * @description:
 * @author: find me
 * @create: 2022-04-13 13:50
 * @Version 1.0
 */
public class FontFactory {
    /**
     * 获取标题样式
     *
     * @return
     * @throws DocumentException
     * @throws IOException
     */
    public static Font getTitleFont() throws DocumentException, IOException {
        BaseFont bf = BaseFont.createFont("STSong-Light", "UniGB-UCS2-H", BaseFont.NOT_EMBEDDED, true);
        Font font = new Font(bf, 22, Font.BOLD, BaseColor.BLACK);//字体
        return font;
    }

    /**
     * 获取正文样式
     *
     * @return
     * @throws DocumentException
     * @throws IOException
     */
    public static Font getBodyFont() throws DocumentException, IOException {
        BaseFont bf = BaseFont.createFont("STSong-Light", "UniGB-UCS2-H", BaseFont.NOT_EMBEDDED, true);
        Font font = new Font(bf, 22, Font.BOLD, BaseColor.BLACK);//字体
        return font;
    }

    /**
     * 获取头部样式
     *
     * @return
     * @throws DocumentException
     * @throws IOException
     */
    public static Font getHeadFont() throws DocumentException, IOException {
        BaseFont bf = BaseFont.createFont("STSong-Light", "UniGB-UCS2-H", BaseFont.NOT_EMBEDDED, true);
        Font font = new Font(bf, 22, Font.BOLD, BaseColor.BLACK);//字体
        return font;
    }

    /**
     * 获取上下文样式
     *
     * @return
     * @throws DocumentException
     * @throws IOException
     */
    public static Font getContextFont() throws DocumentException, IOException {
        BaseFont bf = BaseFont.createFont("STSong-Light", "UniGB-UCS2-H", BaseFont.NOT_EMBEDDED, true);
        Font font = new Font(bf, 10, Font.NORMAL, BaseColor.BLACK);//字体
        return font;
    }

    /**
     * 获回执信息样式
     *
     * @return
     * @throws DocumentException
     * @throws IOException
     */
    public static Font getReceiptHolderFont() throws DocumentException, IOException {
        BaseFont bf = BaseFont.createFont("STSong-Light", "UniGB-UCS2-H", BaseFont.NOT_EMBEDDED, true);
        Font font = new Font(bf, 10, Font.NORMAL, BaseColor.BLACK);//字体
        return font;
    }
}
